

package com.sihai.sample.gateway.servlet;

import cn.hutool.json.JSONObject;
import com.sihai.common.utils.ResponseResult;
import com.sihai.common.vo.BodyTest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author sihai
 */
@Controller
@RequestMapping("/")
@Slf4j
public class IndexController {
  @PostMapping("/hello")
  @ResponseBody
  public String hello() {
    return "B服务已成功处理请求";
  }

  @PostMapping("/route1")
  @ResponseBody
  public ResponseResult route1(@RequestBody JSONObject jsonParam){
    log.info(jsonParam.toJSONString(2));

    BodyTest bodyTest = new BodyTest(1,2);
    return ResponseResult.okResult(bodyTest);
  }
  @PostMapping("/route2")
  @ResponseBody
  public ResponseResult route2(@RequestBody JSONObject jsonParam){
    log.info(jsonParam.toJSONString(2));
    BodyTest bodyTest = new BodyTest(2,2);
    return ResponseResult.okResult(bodyTest);
  }
  @PostMapping("/route3")
  @ResponseBody
  public ResponseResult route3(@RequestBody JSONObject jsonParam){
    log.info(jsonParam.toJSONString(2));
    BodyTest bodyTest = new BodyTest(3,2);
    return ResponseResult.okResult(bodyTest);
  }
}
